********************************************************************************
*
*	Lee-Liou 
*   Where You Work Is Where You Stand: 
*   A Firm-Based Framework for Understanding Trade Opinion
*	Appendix Tables and Figures Code 
*	First Written 1/20/2015
*	Last Modified 1/19/2022
*
********************************************************************************
*	Change path based on the computer name:

use "JGSS 2008.dta", clear

eststo clear

set more off

*	Create industry dummies for industry fixed effects 
tab industry, gen(ind_dum) 
	*NB: Agriculture will be reference industry
	
*	Create trichotomous outcome variable for Ologit results:
********************************************************************************
recode trade (1/3=1) (4=2) (5/7=3), gen(trade3)
	label var trade3 "Japan should limit imports (trichotomous)"
	label define trade3 1 "Disagree" 2 "Neither Agree nor Disagree" 3 "Agree"
	label values trade3 trade3
	
* Descriptive Tables 
********************************************************************************

 latabstat trade female age collgrad redistribution union	///
 cosmo_avg emp_glob jobloss_prob temp_worker comp_disadv mgmt_dum, 	///
 statistics(mean sd median min max) columns(statistics) tf(jgss_descriptives) replace

*	Outcome variable
latab trade, tf(jgss_trade_summary) replace

*	Explanatory variable

gen emp_index = 1 if emp_dom==1
	label var emp_index "Employer Globalization Level"
	replace emp_index = 2 if emp_import==1 & emp_export==0 & emp_offshore==0
	replace emp_index = 3 if emp_export==1 & emp_import==0 & emp_offshore==0
	replace emp_index = 4 if emp_export==1 & emp_import==1 & emp_offshore==0
	replace emp_index = 5 if emp_offshore==1 & emp_import==0 & emp_export==0
	replace emp_index = 6 if emp_offshore==1 & emp_import==1 & emp_export==0
	replace emp_index = 7 if emp_offshore==1 & emp_import==1 & emp_export==1
	label define emp_index 1 "Domestic Firm" 2 "Import Only" 3 "Export Only" ///
		4 "Import and Export Only" 5 "Offshore Affiliate Only" ///
		6 "Offshore and Import Only" 7 "Offshore, Import, and Export"
	label values emp_index emp_index
	
latab emp_index, tf(jgss_emp_index_summary) replace	


***************************Ordered Logit Tables********************************
*	Table A.4 (Testing H1)
********************************************************************************    
set more off

*	Model1: Base Model
eststo tab1_h1: ologit trade3 collgrad emp_glob   ///
   female age union 	///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)


*	Model2: Base Model + comp_disadv
eststo tab1_h1a: ologit trade3 collgrad  emp_glob   ///
   female age union comp_disadv ///
 , cluster(industry)

*	Model3: Base Model + localism
eststo tab1_h1b: ologit trade3 collgrad  emp_glob   ///
   female age union localism ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

*	Model 4: Base Model + LDP - 
eststo tab1_h1c: ologit trade3 collgrad  emp_glob   ///
   female age union LDP   ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
*	Model 5: Base Model + occupational controls
eststo tab1_h1d: ologit trade3 collgrad  emp_glob   ///
   female age union  ///
 task_routine task_offshorability ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
*	Model 6: Attitudinal Controls 
eststo tab1_h1e: ologit trade3 collgrad  emp_glob glob_workers  ///
   female age union redistribution cosmo_avg jobloss_prob	///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry) 
 
esttab tab1_h1 tab1_h1a tab1_h1b tab1_h1c tab1_h1d tab1_h1e  ///
 using "tab1_reduced_ologit_fe_clust.tex", /// */
	replace label nogap  b(2) se  /// 
	star(* 0.10 ** 0.05 *** 0.01)  ///
	ti(Firm Characteristics and Support for Protection (Industry Fixed Effects)) 

eststo clear
	
*	Table A.5 (Testing H2)
********************************************************************************
set more off  

*	Model1: emp_glob X comp_disadv
eststo tab2_h2_ind: xi: ologit trade3 i.emp_glob*i.comp_disadv collgrad  ///
	 female age union , cluster(industry) 

*	Model2: emp_glob X collgrad
eststo tab2_h2_skill: xi: ologit trade3 i.emp_glob*i.collgrad  ///
	 female age union   ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
  
*	Model 3: emp_glob X task_offshorability interaction
eststo tab2_offshore: ologit trade3  collgrad i.emp_glob##c.task_offshorability task_routine  ///
  female age union    ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

*	Model 4: task_routine X task_offshorability interaction 
eststo tab2_routine_offshore: ologit trade3 emp_glob collgrad c.task_routine##c.task_offshorability  ///
  female age  union ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
*	Model 5: task_routine X task_offshorability interaction for domestic employers 
eststo tab2_routine_offshore_0: ologit trade3 collgrad c.task_routine##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==0, cluster(industry)

*	Model 6: task_routine X task_offshorability interaction for globalized employers  
eststo tab2_routine_offshore_1: ologit trade3 collgrad c.task_routine##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==1, cluster(industry)

  
*	Make Table 2:
esttab tab2_h2_ind  tab2_h2_skill tab2_offshore tab2_routine_offshore ///
tab2_routine_offshore_0 tab2_routine_offshore_1 ///
	using "AP_tab2_reduced_ologit_fe_clust.tex", ///
	replace label nogap  b(2) se  /// 
	star(* 0.10 ** 0.05 *** 0.01)  ///
	ti(Conditional Effects of Firm Productivity (Industry Fixed Effects))
	
eststo clear

*	Table A.6(Hypothesis 3 Testing)
********************************************************************************
set more off
 
*	Model1: emp_glob X jobloss_prob
eststo tab3_h3_1: ologit trade3 i.emp_glob##c.jobloss_prob collgrad ///
   female age union   ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
*	Model2: emp_glob X temp_worker
eststo tab3_h3_2: xi: ologit trade3 i.emp_glob*i.temp_worker collgrad ///
   female age union ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry) 
  
 
*	Model3: emp_glob X mgmt
eststo tab3_h3_3: xi: ologit trade3 i.emp_glob*i.mgmt_dum collgrad ///
   female age union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
 
*	Model4: emp_glob X job_satisfaction

recode job_satisfaction(1/4=0) (5=1), gen(satisfied) 

eststo tab3_h3_4: xi: ologit trade3 i.emp_glob*i.satisfied collgrad ///
   female age union   ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

 
*	Make Table 3:
esttab /*tab3_base*/ tab3_h3_1  tab3_h3_2 tab3_h3_3 tab3_h3_4 ///
 using "tab3_reduced_ologit_fe_clust.tex", ///
	replace label nogap  b(2) se  /// 
	star(* 0.10 ** 0.05 *** 0.01)  ///
	ti(Employee Status and Firm Productivity (Industry Fixed Effects))
	
eststo clear

*************************Ologit Figures ****************************************
*	Base Model:
*	No interactions  
********************************************************************************

set seed 020889	

graph set window fontface "CMU Serif"

* Figure  A.1 P(Protection = "Agree") 

ologit trade3 collgrad  emp_glob  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

margins, at(emp_glob=(0 1) ///
 (median) collgrad    female  union age ///
 (means) ) predict(outcome(3)) post
 
*	NB: need to plot the SEs as error bars, not 95% CIs to show statistical significance 
marginsplot, x(emp_glob) recast(scatter) ///
 xscale(range(-0.5(0.5)1.5) titlegap(4)) xtitle("", size(vlarge)) ///
 xlabel(0 `" "Domestic" "Employer" "' 1 `" "Globalized" "Employer" "', labsize(vlarge) nogrid notick) ///
 scheme(s2color) graphregion(color(white)) ///
 ysca(titlegap(4)) ytitle("Protection: P(Agree)", size(vlarge)) ///
 ylabel(, labsize(vlarge)) ///
 title("Employer Type", color(black) size(vlarge)) level(`=round((normal(1)-normal(-1))*100,.01)')
 
graph export "MS_reduced_base_Ologit_fe.png", replace

*	Compare to size of collgrad effect
ologit trade3 collgrad  emp_glob  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

margins, at(collgrad=(0 1) ///
 (median) emp_glob    female  union age ///
 (means) ) predict(outcome(3)) post

marginsplot, x(collgrad) recast(scatter) ///
 xscale(range(-0.5(0.5)1.5) titlegap(4)) xtitle("", size(vlarge)) ///
 xlabel(0 `" "Non-" "Graduate" "' 1 `" "College" "Graduate" "', labsize(vlarge)  nogrid notick) ///
 scheme(s2color) graphregion(color(white)) ///
 ysca(titlegap(4)) ytitle("Protection: P(Agree)", size(vlarge)) ///
 ylabel(, labsize(vlarge)) ///
 title("Skill Level", color(black) size(vlarge)) level(`=round((normal(1)-normal(-1))*100,.01)')
 
graph export "MS_reduced_base_collgrad_Ologit_fe.png", replace
 
*	Compare to size of sector effect
********************************************************************************
*	NB: Cannot use industry fixed effects due to collinearity with comp_disadv
********************************************************************************

ologit trade3 collgrad  emp_glob  comp_disadv ///
  female age  union, cluster(industry)


margins, at(comp_disadv=(0 1) ///
 (median) emp_glob collgrad    female  union age ///
 (means) ) predict(outcome(3)) post

marginsplot, x(comp_disadv) recast(scatter) ///
 xscale(range(-0.5(0.5)1.5) titlegap(4)) xtitle("", size(vlarge)) ///
 /*	double quotes in next line allow line breaks in axis labels*/ ///
 xlabel(0 `" "Comparative" "Advantage" "' 1 `" "Comparative" "Disadvantage" "', labsize(vlarge) nogrid notick) ///
 scheme(s2color) graphregion(color(white)) ///
 ysca(titlegap(4)) ytitle("Protection: P(Agree)", size(vlarge)) ///
 ylabel(, labsize(vlarge)) ///
 title("Sector Competitiveness", color(black) size(vlarge)) level(`=round((normal(1)-normal(-1))*100,.01)')
 
graph export "MS_reduced_base_comp_disadv_Ologit_fe.png", replace


********************************************************************************
*	Base Model:
*	No interactions  
********************************************************************************
*Figure A.2 P(Protection) = "Neutral"

ologit trade3 collgrad  emp_glob  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

margins, at(emp_glob=(0 1) ///
 (median) collgrad    female  union age ///
 (means) ) predict(outcome(2)) post
 
*	NB: need to plot the SEs as error bars, not 95% CIs to show statistical significance 
marginsplot, x(emp_glob) recast(scatter) ///
 xscale(range(-0.5(0.5)1.5) titlegap(4)) xtitle("", size(vlarge)) ///
 xlabel(0 `" "Domestic" "Employer" "' 1 `" "Globalized" "Employer" "', labsize(vlarge) nogrid notick) ///
 scheme(s2color) graphregion(color(white)) ///
 ysca(titlegap(4)) ytitle("Protection: P(Neutral)", size(vlarge)) ///
 ylabel(, labsize(vlarge)) ///
 title("Employer Type", color(black) size(vlarge)) level(`=round((normal(1)-normal(-1))*100,.01)')
 
graph export "MS_reduced_base_Ologit_fe2.png", replace

*	Compare to size of collgrad effect
ologit trade3 collgrad  emp_glob  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

margins, at(collgrad=(0 1) ///
 (median) emp_glob    female  union age ///
 (means) ) predict(outcome(2)) post

marginsplot, x(collgrad) recast(scatter) ///
 xscale(range(-0.5(0.5)1.5) titlegap(4)) xtitle("", size(vlarge)) ///
 xlabel(0 `" "Non-" "Graduate" "' 1 `" "College" "Graduate" "', labsize(vlarge)  nogrid notick) ///
 scheme(s2color) graphregion(color(white)) ///
 ysca(titlegap(4)) ytitle("Protection: P(Neutral)", size(vlarge)) ///
 ylabel(, labsize(vlarge)) ///
 title("Skill Level", color(black) size(vlarge)) level(`=round((normal(1)-normal(-1))*100,.01)')
 
graph export "MS_reduced_base_collgrad_Ologit_fe2.png", replace
 
*	Compare to size of sector effect
********************************************************************************
*	NB: Cannot use industry fixed effects due to collinearity with comp_disadv
********************************************************************************

ologit trade3 collgrad  emp_glob  comp_disadv ///
  female age  union, cluster(industry)


margins, at(comp_disadv=(0 1) ///
 (median) emp_glob collgrad    female  union age ///
 (means) ) predict(outcome(2)) post

marginsplot, x(comp_disadv) recast(scatter) ///
 xscale(range(-0.5(0.5)1.5) titlegap(4)) xtitle("", size(vlarge)) ///
 /*	double quotes in next line allow line breaks in axis labels*/ ///
 xlabel(0 `" "Comparative" "Advantage" "' 1 `" "Comparative" "Disadvantage" "', labsize(vlarge) nogrid notick) ///
 scheme(s2color) graphregion(color(white)) ///
 ysca(titlegap(4)) ytitle("Protection: P(Neutral)", size(vlarge)) ///
 ylabel(, labsize(vlarge)) ///
 title("Sector Competitiveness", color(black) size(vlarge)) level(`=round((normal(1)-normal(-1))*100,.01)')
 
graph export "MS_reduced_base_comp_disadv_Ologit_fe2.png", replace

********************************************************************************
*	Base Model:
*	No interactions  
********************************************************************************
*Figure A.3 P(Protection) = “Disagree”

 ologit trade3 collgrad  emp_glob  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

margins, at(emp_glob=(0 1) ///
 (median) collgrad    female  union age ///
 (means) ) predict(outcome(1)) post
 
*	NB: need to plot the SEs as error bars, not 95% CIs to show statistical significance 
marginsplot, x(emp_glob) recast(scatter) ///
 xscale(range(-0.5(0.5)1.5) titlegap(4)) xtitle("", size(vlarge)) ///
 xlabel(0 `" "Domestic" "Employer" "' 1 `" "Globalized" "Employer" "', labsize(vlarge) nogrid notick) ///
 scheme(s2color) graphregion(color(white)) ///
 ysca(titlegap(4)) ytitle("Protection: P(Disagree)", size(vlarge)) ///
 ylabel(, labsize(vlarge)) ///
 title("Employer Type", color(black) size(vlarge)) level(`=round((normal(1)-normal(-1))*100,.01)')
 
graph export "MS_reduced_base_Ologit_fe1.png", replace

*	Compare to size of collgrad effect
ologit trade3 collgrad  emp_glob  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

margins, at(collgrad=(0 1) ///
 (median) emp_glob    female  union age ///
 (means) ) predict(outcome(1)) post

marginsplot, x(collgrad) recast(scatter) ///
 xscale(range(-0.5(0.5)1.5) titlegap(4)) xtitle("", size(vlarge)) ///
 xlabel(0 `" "Non-" "Graduate" "' 1 `" "College" "Graduate" "', labsize(vlarge)  nogrid notick) ///
 scheme(s2color) graphregion(color(white)) ///
 ysca(titlegap(4)) ytitle("Protection: P(Disagree)", size(vlarge)) ///
 ylabel(, labsize(vlarge)) ///
 title("Skill Level", color(black) size(vlarge)) level(`=round((normal(1)-normal(-1))*100,.01)')
 
graph export "MS_reduced_base_collgrad_Ologit_fe1.png", replace
 
*	Compare to size of sector effect
********************************************************************************
*	NB: Cannot use industry fixed effects due to collinearity with comp_disadv
********************************************************************************

ologit trade3 collgrad  emp_glob  comp_disadv ///
  female age  union, cluster(industry)


margins, at(comp_disadv=(0 1) ///
 (median) emp_glob collgrad    female  union age ///
 (means) ) predict(outcome(1)) post

marginsplot, x(comp_disadv) recast(scatter) ///
 xscale(range(-0.5(0.5)1.5) titlegap(4)) xtitle("", size(vlarge)) ///
 /*	double quotes in next line allow line breaks in axis labels*/ ///
 xlabel(0 `" "Comparative" "Advantage" "' 1 `" "Comparative" "Disadvantage" "', labsize(vlarge) nogrid notick) ///
 scheme(s2color) graphregion(color(white)) ///
 ysca(titlegap(4)) ytitle("Protection: P(Disagree)", size(vlarge)) ///
 ylabel(, labsize(vlarge)) ///
 title("Sector Competitiveness", color(black) size(vlarge)) level(`=round((normal(1)-normal(-1))*100,.01)')
 
graph export "MS_reduced_base_comp_disadv_Ologit_fe1.png", replace

********************************************************************************
*	NNT hypothesis 2:
*	*emp_glob interaction  
******************************************************************************** 
*Figure A.4: P(protection=“Agree”)

********************************************************************************
*	emp_glob*comp_disadv interaction  
********************************************************************************

ologit trade3 emp_glob##comp_disadv collgrad ///
   female age union, cluster(industry)
 
/*
Note that have to set confidence levels at SEs rather than estimate CIs so that 
error bars don't overlap and give the (mistaken) impression of lack of 
significant separation between estimates. 
*/ 


margins, at(comp_disadv=0 emp_glob=0 (median) collgrad    ///
 female  union age (means) ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(CD0_X_EG0, replace)
 
margins, at(comp_disadv=0 emp_glob=1 (median) collgrad    ///
 female  union age (means) ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(CD0_X_EG1, replace) 
 
margins, at(comp_disadv=1 emp_glob=0 (median) collgrad    ///
 female  union age (means) ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(CD1_X_EG0, replace)

margins, at(comp_disadv=1 emp_glob=1 (median) collgrad    ///
 female  union age (means) ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(CD1_X_EG1, replace)  


*	Domestic Firms
combomarginsplot CD0_X_EG0 CD1_X_EG0, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Advantaged" 2 "Disadvantaged", labsize(large)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Agree)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Domestic Employers", size(vlarge) color(black)) ///
name(EG0_X_CD_Ologit_fe, replace) 

graph save "EG0_X_CD_Ologit_fe", replace

*	Globalized Firms
combomarginsplot CD0_X_EG1 CD1_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Advantaged" 2 "Disadvantaged", labsize(large)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Agree)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Globalized Employers", size(vlarge) color(black)) ///
name(EG1_X_CD_Ologit_fe, replace)

graph save "EG1_X_CD_Ologit_fe", replace

*	Combined
graph combine "EG0_X_CD_Ologit_fe" "EG1_X_CD_Ologit_fe", ycommon ///
title("Sector Competitiveness", color(black)) scheme(s2color) graphregion(color(white))

graph export "MS_reduced_comp_disadv_X_emp_glob_Ologit_fe.png", replace

********************************************************************************
*	emp_glob*collgrad interaction
********************************************************************************

ologit trade3 i.emp_glob##collgrad  ///
   female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
margins, at(collgrad=0 emp_glob=0 (median)   ///
 female  union age (means)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') predict(outcome(3)) saving(grad0_X_EG0, replace)
 
margins, at(collgrad=0 emp_glob=1 (median)   ///
 female  union age (means) ) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') predict(outcome(3))  saving(grad0_X_EG1, replace)
 
margins, at(collgrad=1 emp_glob=0 (median)   ///
 female  union age (means)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') predict(outcome(3))  saving(grad1_X_EG0, replace)

margins, at(collgrad=1 emp_glob=1 (median)   ///
 female  union age (means)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') predict(outcome(3))  saving(grad1_X_EG1, replace)  

*	Domestic Employers
combomarginsplot grad0_X_EG0 grad1_X_EG0, recast(scatter) ///
	xscale(range(0.5(0.5)2.5)) xlabel(1 "Non-Grads" 2 "Graduates", labsize(large)) xtitle("", size(vlarge)) ///
	ytitle("Protection: P(Agree)", size(vlarge)) ///
	ylabel(, labsize(vlarge)) ///
	xsca(titlegap(4))	/// *adds gap between title and labels
	scheme(s2color) graphregion(color(white)) ///
	title("Domestic Employers", size(vlarge) color(black)) ///
	name(EG0_X_grad_Ologit_fe, replace)

graph save "EG0_X_grad_Ologit_fe", replace
	
*	Globalized Employers
combomarginsplot grad0_X_EG1 grad1_X_EG1, recast(scatter) ///
	xscale(range(0.5(0.5)2.5)) xlabel(1 "Non-Grads" 2 "Graduates", labsize(large)) xtitle("", size(vlarge)) ///
	ytitle("Protection: P(Agree)", size(vlarge)) ///
	ylabel(, labsize(vlarge)) ///
	xsca(titlegap(4))	/// *adds gap between title and labels
	scheme(s2color) graphregion(color(white)) ///
	title("Globalized Employers", size(vlarge) color(black)) ///
	name(EG1_X_grad_Ologit_fe, replace)

graph save "EG1_X_grad_Ologit_fe", replace

*	Combined
graph combine "EG0_X_grad_Ologit_fe" "EG1_X_grad_Ologit_fe", ycommon ///
title("Skill Level", color(black)) scheme(s2color) graphregion(color(white))

graph export "MS_reduced_collgrad_X_emp_glob_Ologit_fe.png", replace


*	Margins at mean values of task_routine:
********************************************************************************
set more off

*	Calculate margins for domestic only, and globalized only

ologit trade3 emp_glob  collgrad c.task_routine##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==0, cluster(industry)
 
margins if emp_glob==0, at(task_offshorability=(-3.2(0.2)3.2) ///
 (median) collgrad   female  union age ///
 (means) task_routine ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(offshore_routine_EG0_mean_Ologit_fe, replace)
 
ologit trade3 emp_glob  collgrad c.task_routine##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==1, cluster(industry)
 
margins if emp_glob==1, at(task_offshorability=(-3.2(0.2)3.2) ///
 (median) collgrad   female  union age ///
 (means) task_routine ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(offshore_routine_EG1_mean_Ologit_fe, replace)
 
*	Domestic employers only
marginsplot using "offshore_routine_EG0_mean_Ologit_fe", x(task_offshorability) recast(line) ///
plotopts(lcolor(maroon)) ///
title("Domestic", color(black) size(vlarge)) ///
 ytitle("Protection: P(Agree)", size(vlarge)) ysc(titlegap(5)) ///
 ylabel(, labsize(vlarge)) ///
 xtitle("Task Offshorability", size(vlarge))  ///
 xlabel(, labsize(vlarge)) xsc(titlegap(5)) /// //use xsc option to create space between axis labels and axis title//
 scheme(s2color) graphregion(color(white)) ///
 recastci(rarea) ciopts(color(maroon%15)) ///
 name(off_routine_EG0_mean_Ologit_fe, replace) 
 
graph save "offshore_routine_EG0_mean_Ologit_fe", replace

*	Globalized employers only
marginsplot using "offshore_routine_EG1_mean_Ologit_fe", x(task_offshorability) recast(line) ///
title("Globalized", color(black) size(vlarge)) ///
 ytitle("Protection: P(Agree)", size(vlarge)) ysc(titlegap(5)) ///
 ylabel(, labsize(vlarge)) ///
 xtitle("Task Offshorability", size(vlarge))  ///
 xlabel(, labsize(vlarge)) xsc(titlegap(5)) /// //use xsc option to create space between axis labels and axis title//
 scheme(s2color) graphregion(color(white)) ///
 recastci(rarea) ciopts(color(%15)) ///
 name(off_routine_EG1_mean_Ologit_fe, replace) 
 
graph save "offshore_routine_EG1_mean_Ologit_fe", replace

*	Combine domestic and globalized for comparison:
graph combine "offshore_routine_EG0_mean_Ologit_fe" "offshore_routine_EG1_mean_Ologit_fe", ycommon ///
title("Exposure to Offshoring at Mean Task Routineness", color(black)) rows(1) scheme(s2color) ///
graphregion(color(white))

graph export "MS_reduced_offshore_routine_mean_duo_Ologit_fe.png", replace

*	Margins at mean values of task_offshorability:
********************************************************************************
set more off

*	Calculate margins for domestic only, and globalized only

ologit trade3 emp_glob  collgrad c.task_routine##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==0, cluster(industry)
 
margins if emp_glob==0, at(task_routine=(1.2(0.2)8.6) ///
 (median) collgrad   female  union age ///
 (means) task_offshorability ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(routine_offshore_EG0_mean_Ologit_fe, replace)
 
ologit trade3 emp_glob  collgrad c.task_routine##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==1, cluster(industry)
 
margins if emp_glob==1, at(task_routine=(1.2(0.2)8.6) ///
 (median) collgrad   female  union age ///
 (means) task_offshorability ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(routine_offshore_EG1_mean_Ologit_fe, replace)
 

*	Domestic employers only
marginsplot using "routine_offshore_EG0_mean_Ologit_fe", x(task_routine) recast(line) ///
plotopts(lcolor(maroon)) ///
title("Domestic", color(black) size(vlarge)) ///
 ytitle("Protection: P(Agree)", size(vlarge)) ysc(titlegap(5)) ///
 ylabel(, labsize(vlarge)) ///
 xtitle("Task Routineness", size(vlarge))  ///
 xlabel(1(1)9, labsize(vlarge)) xsc(titlegap(5)) /// //use xsc option to create space between axis labels and axis title//
 scheme(s2color) graphregion(color(white)) ///
 recastci(rarea) ciopts(color(maroon%15)) ///
 name(routine_off_EG0_mean_Ologit_fe, replace) 
 
graph save "routine_offshore_EG0_mean_Ologit_fe", replace

*	Globalized employers only
marginsplot using "routine_offshore_EG1_mean_Ologit_fe", x(task_routine) recast(line) ///
title("Globalized", color(black) size(vlarge)) ///
 ytitle("Protection: P(Agree)", size(vlarge)) ysc(titlegap(5)) ///
 ylabel(, labsize(vlarge)) ///
 xtitle("Task Routineness", size(vlarge))  ///
 xlabel(1(1)9, labsize(vlarge)) xsc(titlegap(5)) /// //use xsc option to create space between axis labels and axis title//
 scheme(s2color) graphregion(color(white)) ///
 recastci(rarea) ciopts(color(%15)) ///
 name(routine_off_EG1_mean_Ologit_fe, replace) 
 
graph save "routine_offshore_EG1_mean_Ologit_fe", replace

*	Combine domestic and globalized for comparison:
graph combine "routine_offshore_EG0_mean_Ologit_fe" "routine_offshore_EG1_mean_Ologit_fe", ycommon ///
title("Task Routineness at Mean Offshorability", color(black)) rows(1) scheme(s2color) ///
graphregion(color(white))

graph export "MS_reduced_routine_offshore_mean_duo_Ologit_fe.png", replace

********************************************************************************
*	NNT hypothesis 2:
*	*emp_glob interaction  
******************************************************************************** 
*Figure A.5 P(Protection) = "Neutral"

********************************************************************************
*	emp_glob*comp_disadv interaction  
********************************************************************************
 
ologit trade3 emp_glob##comp_disadv collgrad ///
   female age union, cluster(industry)
 
/*
Note that have to set confidence levels at SEs rather than estimate CIs so that 
error bars don't overlap and give the (mistaken) impression of lack of 
significant separation between estimates. 
*/ 


margins, at(comp_disadv=0 emp_glob=0 (median) collgrad    ///
 female  union age (means) ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(CD0_X_EG0, replace)
 
margins, at(comp_disadv=0 emp_glob=1 (median) collgrad    ///
 female  union age (means) ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(CD0_X_EG1, replace) 
 
margins, at(comp_disadv=1 emp_glob=0 (median) collgrad    ///
 female  union age (means) ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(CD1_X_EG0, replace)

margins, at(comp_disadv=1 emp_glob=1 (median) collgrad    ///
 female  union age (means) ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(CD1_X_EG1, replace)  

*	Domestic Firms
combomarginsplot CD0_X_EG0 CD1_X_EG0, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Advantaged" 2 "Disadvantaged", labsize(large)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Neutral)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Domestic Employers", size(vlarge) color(black)) ///
name(EG0_X_CD_Ologit_fe2, replace) 

graph save "EG0_X_CD_Ologit_fe2", replace

*	Globalized Firms
combomarginsplot CD0_X_EG1 CD1_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Advantaged" 2 "Disadvantaged", labsize(large)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Neutral)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Globalized Employers", size(vlarge) color(black)) ///
name(EG1_X_CD_Ologit_fe2, replace)

graph save "EG1_X_CD_Ologit_fe2", replace

*	Combined
graph combine "EG0_X_CD_Ologit_fe2" "EG1_X_CD_Ologit_fe2", ycommon ///
title("Sector Competitiveness", color(black)) scheme(s2color) graphregion(color(white))

graph export "MS_reduced_comp_disadv_X_emp_glob_Ologit_fe2.png", replace

********************************************************************************
*	emp_glob*collgrad interaction
********************************************************************************

ologit trade3 i.emp_glob##collgrad  ///
   female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
margins, at(collgrad=0 emp_glob=0 (median)   ///
 female  union age (means)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') predict(outcome(2)) saving(colgrad0_X_EG0, replace)
 
margins, at(collgrad=0 emp_glob=1 (median)   ///
 female  union age (means) ) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') predict(outcome(2))  saving(colgrad0_X_EG1, replace)
 
margins, at(collgrad=1 emp_glob=0 (median)   ///
 female  union age (means)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') predict(outcome(2))  saving(colgrad1_X_EG0, replace)

margins, at(collgrad=1 emp_glob=1 (median)   ///
 female  union age (means)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') predict(outcome(2))  saving(colgrad1_X_EG1, replace)  

*	Domestic Employers
combomarginsplot colgrad0_X_EG0 colgrad1_X_EG0, recast(scatter) ///
	xscale(range(0.5(0.5)2.5)) xlabel(1 "Non-Grads" 2 "Graduates", labsize(large)) xtitle("", size(vlarge)) ///
	ytitle("Protection: P(Neutral)", size(vlarge)) ///
	ylabel(, labsize(vlarge)) ///
	xsca(titlegap(4))	/// *adds gap between title and labels
	scheme(s2color) graphregion(color(white)) ///
	title("Domestic Employers", size(vlarge) color(black)) ///
	name(EG0_X_grad_Ologit_fe2, replace)

graph save "EG0_X_grad_Ologit_fe2", replace
	
*	Globalized Employers
combomarginsplot colgrad0_X_EG1 colgrad1_X_EG1, recast(scatter) ///
	xscale(range(0.5(0.5)2.5)) xlabel(1 "Non-Grads" 2 "Graduates", labsize(large)) xtitle("", size(vlarge)) ///
	ytitle("Protection: P(Neutral)", size(vlarge)) ///
	ylabel(, labsize(vlarge)) ///
	xsca(titlegap(4))	/// *adds gap between title and labels
	scheme(s2color) graphregion(color(white)) ///
	title("Globalized Employers", size(vlarge) color(black)) ///
	name(EG1_X_grad_Ologit_fe2, replace)

graph save "EG1_X_grad_Ologit_fe2", replace

*	Combined
graph combine "EG0_X_grad_Ologit_fe2" "EG1_X_grad_Ologit_fe2", ycommon ///
title("Skill Level", color(black)) scheme(s2color) graphregion(color(white))

graph export "MS_reduced_collgrad_X_emp_glob_Ologit_fe2.png", replace


*	Margins at mean values of task_routine:
********************************************************************************
set more off

*	Calculate margins for domestic only, and globalized only
 
ologit trade3 emp_glob  collgrad c.task_routine##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==0, cluster(industry)
 
margins if emp_glob==0, at(task_offshorability=(-3.2(0.2)3.2) ///
 (median) collgrad   female  union age ///
 (means) task_routine ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(offshore_routine_EG0_mean_Ologit_fe2, replace)
 
ologit trade3 emp_glob  collgrad c.task_routine##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==1, cluster(industry)
 
margins if emp_glob==1, at(task_offshorability=(-3.2(0.2)3.2) ///
 (median) collgrad   female  union age ///
 (means) task_routine ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(offshore_routine_EG1_mean_Ologit_fe2, replace)
 
*	Domestic employers only
marginsplot using "offshore_routine_EG0_mean_Ologit_fe2", x(task_offshorability) recast(line) ///
plotopts(lcolor(maroon)) ///
title("Domestic", color(black) size(vlarge)) ///
 ytitle("Protection: P(Neutral)", size(vlarge)) ysc(titlegap(5)) ///
 ylabel(, labsize(vlarge)) ///
 xtitle("Task Offshorability", size(vlarge))  ///
 xlabel(, labsize(vlarge)) xsc(titlegap(5)) /// //use xsc option to create space between axis labels and axis title//
 scheme(s2color) graphregion(color(white)) ///
 recastci(rarea) ciopts(color(maroon%15)) ///
 name(off_routine_EG0_mean_Ologit_fe2, replace) 
 
graph save "offshore_routine_EG0_mean_Ologit_fe2", replace

*	Globalized employers only
marginsplot using "offshore_routine_EG1_mean_Ologit_fe2", x(task_offshorability) recast(line) ///
title("Globalized", color(black) size(vlarge)) ///
 ytitle("Protection: P(Neutral)", size(vlarge)) ysc(titlegap(5)) ///
 ylabel(, labsize(vlarge)) ///
 xtitle("Task Offshorability", size(vlarge))  ///
 xlabel(, labsize(vlarge)) xsc(titlegap(5)) /// //use xsc option to create space between axis labels and axis title//
 scheme(s2color) graphregion(color(white)) ///
 recastci(rarea) ciopts(color(%15)) ///
 name(off_routine_EG1_mean_Ologit_fe2, replace) 
 
graph save "offshore_routine_EG1_mean_Ologit_fe2", replace

*	Combine domestic and globalized for comparison:
graph combine "offshore_routine_EG0_mean_Ologit_fe2" "offshore_routine_EG1_mean_Ologit_fe2", ycommon ///
title("Exposure to Offshoring at Mean Task Routineness", color(black)) rows(1) scheme(s2color) ///
graphregion(color(white))

graph export "MS_reduced_offshore_routine_mean_duo_Ologit_fe2.png", replace

*	Margins at mean values of task_offshorability:
********************************************************************************
set more off

*	Calculate margins for domestic only, and globalized only
 
ologit trade3 emp_glob  collgrad c.task_routine##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==0, cluster(industry)
 
margins if emp_glob==0, at(task_routine=(1.2(0.2)8.6) ///
 (median) collgrad   female  union age ///
 (means) task_offshorability ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(routine_offshore_EG0_mean_Ologit_fe2, replace)
 
ologit trade3 emp_glob  collgrad c.task_routine##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==1, cluster(industry)
 
margins if emp_glob==1, at(task_routine=(1.2(0.2)8.6) ///
 (median) collgrad   female  union age ///
 (means) task_offshorability ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(routine_offshore_EG1_mean_Ologit_fe2, replace)
 
*	Domestic employers only
marginsplot using "routine_offshore_EG0_mean_Ologit_fe2", x(task_routine) recast(line) ///
plotopts(lcolor(maroon)) ///
title("Domestic", color(black) size(vlarge)) ///
 ytitle("Protection: P(Neutral)", size(vlarge)) ysc(titlegap(5)) ///
 ylabel(, labsize(vlarge)) ///
 xtitle("Task Routineness", size(vlarge))  ///
 xlabel(1(1)9, labsize(vlarge)) xsc(titlegap(5)) /// //use xsc option to create space between axis labels and axis title//
 scheme(s2color) graphregion(color(white)) ///
 recastci(rarea) ciopts(color(maroon%15)) ///
 name(routine_off_EG0_mean_Ologit_fe2, replace) 
 
graph save "routine_offshore_EG0_mean_Ologit_fe2", replace

*	Globalized employers only
marginsplot using "routine_offshore_EG1_mean_Ologit_fe2", x(task_routine) recast(line) ///
title("Globalized", color(black) size(vlarge)) ///
 ytitle("Protection: P(Neutral)", size(vlarge)) ysc(titlegap(5)) ///
 ylabel(, labsize(vlarge)) ///
 xtitle("Task Routineness", size(vlarge))  ///
 xlabel(1(1)9, labsize(vlarge)) xsc(titlegap(5)) /// //use xsc option to create space between axis labels and axis title//
 scheme(s2color) graphregion(color(white)) ///
 recastci(rarea) ciopts(color(%15)) ///
 name(routine_off_EG1_mean_Ologit_fe2, replace) 
 
graph save "routine_offshore_EG1_mean_Ologit_fe2", replace

*	Combine domestic and globalized for comparison:
graph combine "routine_offshore_EG0_mean_Ologit_fe2" "routine_offshore_EG1_mean_Ologit_fe2", ycommon ///
title("Task Routineness at Mean Offshorability", color(black)) rows(1) scheme(s2color) ///
graphregion(color(white))

graph export "MS_reduced_routine_offshore_mean_duo_Ologit_fe2.png", replace

********************************************************************************
*	NNT hypothesis 2:
*	*emp_glob interaction  
******************************************************************************** 
*Figure A.6 P(Protection) = “Disagree”

********************************************************************************
*	emp_glob*comp_disadv interaction  
********************************************************************************
 
ologit trade3 emp_glob##comp_disadv collgrad ///
   female age union , cluster(industry)
 
/*
Note that have to set confidence levels at SEs rather than estimate CIs so that 
error bars don't overlap and give the (mistaken) impression of lack of 
significant separation between estimates. 
*/ 


margins, at(comp_disadv=0 emp_glob=0 (median) collgrad    ///
 female  union age (means) ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(CD0_X_EG0, replace)
 
margins, at(comp_disadv=0 emp_glob=1 (median) collgrad    ///
 female  union age (means) ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(CD0_X_EG1, replace) 
 
margins, at(comp_disadv=1 emp_glob=0 (median) collgrad    ///
 female  union age (means) ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(CD1_X_EG0, replace)

margins, at(comp_disadv=1 emp_glob=1 (median) collgrad    ///
 female  union age (means) ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(CD1_X_EG1, replace)  

*	Domestic Firms
combomarginsplot CD0_X_EG0 CD1_X_EG0, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Advantaged" 2 "Disadvantaged", labsize(large)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Disagree)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Domestic Employers", size(vlarge) color(black)) ///
name(EG0_X_CD_Ologit_fe1, replace) 

graph save "EG0_X_CD_Ologit_fe1", replace

*	Globalized Firms
combomarginsplot CD0_X_EG1 CD1_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Advantaged" 2 "Disadvantaged", labsize(large)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Disagree)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Globalized Employers", size(vlarge) color(black)) ///
name(EG1_X_CD_Ologit_fe1, replace)

graph save "EG1_X_CD_Ologit_fe1", replace

*	Combined
graph combine "EG0_X_CD_Ologit_fe1" "EG1_X_CD_Ologit_fe1", ycommon ///
title("Sector Competitiveness", color(black)) scheme(s2color) graphregion(color(white))

graph export "MS_reduced_comp_disadv_X_emp_glob_Ologit_fe1.png", replace

********************************************************************************
*	emp_glob*collgrad interaction
********************************************************************************

ologit trade3 i.emp_glob##collgrad  ///
   female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
margins, at(collgrad=0 emp_glob=0 (median)   ///
 female  union age (means)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') predict(outcome(1)) saving(colgrad0_X_EG0, replace)
 
margins, at(collgrad=0 emp_glob=1 (median)   ///
 female  union age (means) ) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') predict(outcome(1))  saving(colgrad0_X_EG1, replace)
 
margins, at(collgrad=1 emp_glob=0 (median)   ///
 female  union age (means)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') predict(outcome(1))  saving(colgrad1_X_EG0, replace)

margins, at(collgrad=1 emp_glob=1 (median)   ///
 female  union age (means)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') predict(outcome(1))  saving(colgrad1_X_EG1, replace)  

*	Domestic Employers
combomarginsplot colgrad0_X_EG0 colgrad1_X_EG0, recast(scatter) ///
	xscale(range(0.5(0.5)2.5)) xlabel(1 "Non-Grads" 2 "Graduates", labsize(large)) xtitle("", size(vlarge)) ///
	ytitle("Protection: P(Disagree)", size(vlarge)) ///
	ylabel(, labsize(vlarge)) ///
	xsca(titlegap(4))	/// *adds gap between title and labels
	scheme(s2color) graphregion(color(white)) ///
	title("Domestic Employers", size(vlarge) color(black)) ///
	name(EG0_X_grad_Ologit_fe1, replace)

graph save "EG0_X_grad_Ologit_fe1", replace
	
*	Globalized Employers
combomarginsplot colgrad0_X_EG1 colgrad1_X_EG1, recast(scatter) ///
	xscale(range(0.5(0.5)2.5)) xlabel(1 "Non-Grads" 2 "Graduates", labsize(large)) xtitle("", size(vlarge)) ///
	ytitle("Protection: P(Disagree)", size(vlarge)) ///
	ylabel(, labsize(vlarge)) ///
	xsca(titlegap(4))	/// *adds gap between title and labels
	scheme(s2color) graphregion(color(white)) ///
	title("Globalized Employers", size(vlarge) color(black)) ///
	name(EG1_X_grad_Ologit_fe1, replace)

graph save "EG1_X_grad_Ologit_fe1", replace

*	Combined
graph combine "EG0_X_grad_Ologit_fe1" "EG1_X_grad_Ologit_fe1", ycommon ///
title("Skill Level", color(black)) scheme(s2color) graphregion(color(white))

graph export "MS_reduced_collgrad_X_emp_glob_Ologit_fe1.png", replace


*	Margins at mean values of task_routine:
********************************************************************************
set more off

*	Calculate margins for domestic only, and globalized only
 
ologit trade3 emp_glob  collgrad c.task_routine##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==0, cluster(industry)
 
margins if emp_glob==0, at(task_offshorability=(-3.2(0.2)3.2) ///
 (median) collgrad   female  union age ///
 (means) task_routine ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(offshore_routine_EG0_mean_Ologit_fe1, replace)
 
ologit trade3 emp_glob  collgrad c.task_routine##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==1, cluster(industry)
 
margins if emp_glob==1, at(task_offshorability=(-3.2(0.2)3.2) ///
 (median) collgrad   female  union age ///
 (means) task_routine ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(offshore_routine_EG1_mean_Ologit_fe1, replace)
 
*	Domestic employers only
marginsplot using "offshore_routine_EG0_mean_Ologit_fe1", x(task_offshorability) recast(line) ///
plotopts(lcolor(maroon)) ///
title("Domestic", color(black) size(vlarge)) ///
 ytitle("Protection: P(Disagree)", size(vlarge)) ysc(titlegap(5)) ///
 ylabel(, labsize(vlarge)) ///
 xtitle("Task Offshorability", size(vlarge))  ///
 xlabel(, labsize(vlarge)) xsc(titlegap(5)) /// //use xsc option to create space between axis labels and axis title//
 scheme(s2color) graphregion(color(white)) ///
 recastci(rarea) ciopts(color(maroon%15)) ///
 name(off_routine_EG0_mean_Ologit_fe1, replace) 
 
graph save "offshore_routine_EG0_mean_Ologit_fe1", replace

*	Globalized employers only
marginsplot using "offshore_routine_EG1_mean_Ologit_fe1", x(task_offshorability) recast(line) ///
title("Globalized", color(black) size(vlarge)) ///
 ytitle("Protection: P(Disagree)", size(vlarge)) ysc(titlegap(5)) ///
 ylabel(, labsize(vlarge)) ///
 xtitle("Task Offshorability", size(vlarge))  ///
 xlabel(, labsize(vlarge)) xsc(titlegap(5)) /// //use xsc option to create space between axis labels and axis title//
 scheme(s2color) graphregion(color(white)) ///
 recastci(rarea) ciopts(color(%15)) ///
 name(off_routine_EG1_mean_Ologit_fe1, replace) 
 
graph save "offshore_routine_EG1_mean_Ologit_fe1", replace

*	Combine domestic and globalized for comparison:
graph combine "offshore_routine_EG0_mean_Ologit_fe1" "offshore_routine_EG1_mean_Ologit_fe1", ycommon ///
title("Exposure to Offshoring at Mean Task Routineness", color(black)) rows(1) scheme(s2color) ///
graphregion(color(white))

graph export "MS_reduced_offshore_routine_mean_duo_Ologit_fe1.png", replace

*	Margins at mean values of task_offshorability:
********************************************************************************
set more off

*	Calculate margins for domestic only, and globalized only
ologit trade3 emp_glob  collgrad c.task_routine##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==0, cluster(industry)
 
margins if emp_glob==0, at(task_routine=(1.2(0.2)8.6) ///
 (median) collgrad   female  union age ///
 (means) task_offshorability ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(routine_offshore_EG0_mean_Ologit_fe1, replace)
 
ologit trade3 emp_glob  collgrad c.task_routine##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==1, cluster(industry)
 
margins if emp_glob==1, at(task_routine=(1.2(0.2)8.6) ///
 (median) collgrad   female  union age ///
 (means) task_offshorability ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(routine_offshore_EG1_mean_Ologit_fe1, replace)
 
*	Domestic employers only
marginsplot using "routine_offshore_EG0_mean_Ologit_fe1", x(task_routine) recast(line) ///
plotopts(lcolor(maroon)) ///
title("Domestic", color(black) size(vlarge)) ///
 ytitle("Protection: P(Disagree)", size(vlarge)) ysc(titlegap(5)) ///
 ylabel(, labsize(vlarge)) ///
 xtitle("Task Routineness", size(vlarge))  ///
 xlabel(1(1)9, labsize(vlarge)) xsc(titlegap(5)) /// //use xsc option to create space between axis labels and axis title//
 scheme(s2color) graphregion(color(white)) ///
 recastci(rarea) ciopts(color(maroon%15)) ///
 name(routine_off_EG0_mean_Ologit_fe1, replace) 
 
graph save "routine_offshore_EG0_mean_Ologit_fe1", replace

*	Globalized employers only
marginsplot using "routine_offshore_EG1_mean_Ologit_fe1", x(task_routine) recast(line) ///
title("Globalized", color(black) size(vlarge)) ///
 ytitle("Protection: P(Disagree)", size(vlarge)) ysc(titlegap(5)) ///
 ylabel(, labsize(vlarge)) ///
 xtitle("Task Routineness", size(vlarge))  ///
 xlabel(1(1)9, labsize(vlarge)) xsc(titlegap(5)) /// //use xsc option to create space between axis labels and axis title//
 scheme(s2color) graphregion(color(white)) ///
 recastci(rarea) ciopts(color(%15)) ///
 name(routine_off_EG1_mean_Ologit_fe1, replace) 
 
graph save "routine_offshore_EG1_mean_Ologit_fe1", replace

*	Combine domestic and globalized for comparison:
graph combine "routine_offshore_EG0_mean_Ologit_fe1" "routine_offshore_EG1_mean_Ologit_fe1", ycommon ///
title("Task Routineness at Mean Offshorability", color(black)) rows(1) scheme(s2color) ///
graphregion(color(white))

graph export "MS_reduced_routine_offshore_mean_duo_Ologit_fe1.png", replace

********************************************************************************
*	NNT hypothesis 3:
*	*Intra-Firm Variation* 
******************************************************************************** 

*Figure A.7: P(protection=“Agree”)

******************************************************************************** 
*	job insecurity*emp_glob interaction
********************************************************************************
*	Dichotomizing 

recode jobloss_prob (1/2=0) (3/4=1), gen(job_notsafe)
	label var job_notsafe "At least `fairly likely' to lose job in next 12 months?"
	label values job_notsafe ny
	
ologit trade3 emp_glob##job_notsafe collgrad   ///
  female age  union  ///
 ind_dum2-ind_dum21, cluster(industry)
 
margins, at(job_notsafe=0 emp_glob=0 (median) collgrad   ///
 female  union age (means) ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(JNS0_X_EG0, replace)
 
margins, at(job_notsafe=0 emp_glob=1 (median) collgrad   ///
 female  union age (means) ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(JNS0_X_EG1, replace)
 
margins, at(job_notsafe=1 emp_glob=0 (median) collgrad   ///
 female  union age (means) ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(JNS1_X_EG0, replace)

margins, at(job_notsafe=1 emp_glob=1 (median) collgrad   ///
 female  union age (means) ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(JNS1_X_EG1, replace)  

*	Job Secure 
combomarginsplot JNS0_X_EG0 JNS0_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Domestic" 2 "Globalized", labsize(vlarge)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Agree)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Job Secure", size(vlarge) color(black)) ///
name(JNS0_X_EG, replace)

graph save "JNS0_X_EG_Ologit_fe", replace

*	Job Not Secure
combomarginsplot JNS1_X_EG0 JNS1_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Domestic" 2 "Globalized", labsize(vlarge)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Agree)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Job Not Secure", size(vlarge) color(black)) ///
name(JNS1_X_EG, replace) 

graph save "JNS1_X_EG_Ologit_fe", replace

*	Combined
graph combine "JNS1_X_EG_Ologit_fe" "JNS0_X_EG_Ologit_fe", ycommon ///
title("Job Security", color(black)) scheme(s2color) graphregion(color(white))

graph export "MS_reduced_emp_glob_X_job_notsafe_Ologit_fe.png", replace

******************************************************************************** 
*	temp_worker*emp_glob interaction
********************************************************************************

ologit trade3 i.emp_glob##temp_worker collgrad  ///
   female age  union  ///
 ind_dum2-ind_dum21, cluster(industry)
 
margins, at(temp_worker=0 emp_glob=0 (median)   ///
 female  union age collgrad (means) ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(temp0_X_EG0, replace)
 
margins, at(temp_worker=0 emp_glob=1 (median)   ///
 female  union age collgrad (means) ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(temp0_X_EG1, replace)
 
margins, at(temp_worker=1 emp_glob=0 (median)   ///
 female  union age collgrad (means) ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(temp1_X_EG0, replace)

margins, at(temp_worker=1 emp_glob=1 (median)   ///
 female  union age collgrad (means) ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(temp1_X_EG1, replace)  
 
*	Permanent Employees 
combomarginsplot temp0_X_EG0 temp0_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Domestic" 2 "Globalized", labsize(vlarge)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Agree)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Permanent Employees", size(vlarge) color(black)) ///
name(temp0_X_EG_Ologit_fe, replace)

graph save "temp0_X_EG_Ologit_fe", replace

*	Temporary Employees
combomarginsplot temp1_X_EG0 temp1_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Domestic" 2 "Globalized", labsize(vlarge)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Agree)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Temporary Employees", size(vlarge) color(black)) ///
name(temp1_X_EG_Ologit_fe, replace)

graph save "temp1_X_EG_Ologit_fe", replace

*	Combined
graph combine "temp1_X_EG_Ologit_fe" "temp0_X_EG_Ologit_fe", ycommon ///
title("Temporary Work Status", color(black)) scheme(s2color) graphregion(color(white))

graph export "MS_reduced_emp_glob_X_temp_worker_Ologit_fe.png", replace 

********************************************************************************
*	mgmt*emp_glob interaction
********************************************************************************

*	Having an executive position is another measure of skill level (besides education)

ologit trade3 i.emp_glob##mgmt_dum collgrad   ///
   female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
margins, at(mgmt_dum=0 emp_glob=0 (median)    ///
 female  union age collgrad (means) ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(mgmt_dum0_X_EG0, replace)
 
margins, at(mgmt_dum=0 emp_glob=1 (median)    ///
 female  union age collgrad (means) ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(mgmt_dum0_X_EG1, replace)
 
margins, at(mgmt_dum=1 emp_glob=0 (median)    ///
 female  union age collgrad (means) ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(mgmt_dum1_X_EG0, replace)

margins, at(mgmt_dum=1 emp_glob=1 (median)    ///
 female  union age collgrad (means) ) predict(outcome(3)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(mgmt_dum1_X_EG1, replace)  
 
*	Non-Executives 
combomarginsplot mgmt_dum0_X_EG0 mgmt_dum0_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Domestic" 2 "Globalized", labsize(vlarge)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Agree)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Non-Managers", size(vlarge) color(black)) ///
name(mgmt_dum0_X_EG_Ologit_fe, replace)

graph save "mgmt_dum0_X_EG_Ologit_fe", replace

*	Executives
combomarginsplot mgmt_dum1_X_EG0 mgmt_dum1_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Domestic" 2 "Globalized", labsize(vlarge)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Agree)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Managers", size(vlarge) color(black)) ///
name(mgmt_dum1_X_EG_Ologit_fe, replace)

graph save "mgmt_dum1_X_EG_Ologit_fe", replace

*	Combined
graph combine "mgmt_dum0_X_EG_Ologit_fe" "mgmt_dum1_X_EG_Ologit_fe", ycommon ///
title("Job Role", color(black)) scheme(s2color) graphregion(color(white))

graph export "MS_reduced_emp_glob_X_mgmt_dum_Ologit_fe.png", replace

********************************************************************************
*	NNT hypothesis 2:
*	*Intra-Firm Variation*
******************************************************************************** 
*Figure A.8 P(Protection) = "Neutral"

******************************************************************************** 
*	job insecurity*emp_glob interaction
********************************************************************************
*	Dichotomizing 

recode jobloss_prob (1/2=0) (3/4=1), gen(job_notsafe)
	label var job_notsafe "At least `fairly likely' to lose job in next 12 months?"
	label values job_notsafe ny
	
ologit trade3 emp_glob##job_notsafe collgrad   ///
  female age  union  ///
 ind_dum2-ind_dum21, cluster(industry)
 
margins, at(job_notsafe=0 emp_glob=0 (median) collgrad   ///
 female  union age (means) ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(JNS0_X_EG0, replace)
 
margins, at(job_notsafe=0 emp_glob=1 (median) collgrad   ///
 female  union age (means) ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(JNS0_X_EG1, replace)
 
margins, at(job_notsafe=1 emp_glob=0 (median) collgrad   ///
 female  union age (means) ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(JNS1_X_EG0, replace)

margins, at(job_notsafe=1 emp_glob=1 (median) collgrad   ///
 female  union age (means) ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(JNS1_X_EG1, replace)  

*	Job Secure 
combomarginsplot JNS0_X_EG0 JNS0_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Domestic" 2 "Globalized", labsize(vlarge)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Neutral)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Job Secure", size(vlarge) color(black)) ///
name(JNS0_X_EG, replace)

graph save "JNS0_X_EG_Ologit_fe2", replace

*	Job Not Secure
combomarginsplot JNS1_X_EG0 JNS1_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Domestic" 2 "Globalized", labsize(vlarge)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Neutral)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Job Not Secure", size(vlarge) color(black)) ///
name(JNS1_X_EG, replace) 

graph save "JNS1_X_EG_Ologit_fe2", replace

*	Combined
graph combine "JNS1_X_EG_Ologit_fe2" "JNS0_X_EG_Ologit_fe2", ycommon ///
title("Job Security", color(black)) scheme(s2color) graphregion(color(white))

graph export "MS_reduced_emp_glob_X_job_notsafe_Ologit_fe2.png", replace

******************************************************************************** 
*	temp_worker*emp_glob interaction
********************************************************************************
	
ologit trade3 i.emp_glob##temp_worker collgrad  ///
   female age  union  ///
 ind_dum2-ind_dum21, cluster(industry)
 
margins, at(temp_worker=0 emp_glob=0 (median)   ///
 female  union age collgrad (means) ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(temp0_X_EG0, replace)
 
margins, at(temp_worker=0 emp_glob=1 (median)   ///
 female  union age collgrad (means) ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(temp0_X_EG1, replace)
 
margins, at(temp_worker=1 emp_glob=0 (median)   ///
 female  union age collgrad (means) ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(temp1_X_EG0, replace)

margins, at(temp_worker=1 emp_glob=1 (median)   ///
 female  union age collgrad (means) ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(temp1_X_EG1, replace)  
 
*	Permanent Employees 
combomarginsplot temp0_X_EG0 temp0_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Domestic" 2 "Globalized", labsize(vlarge)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Neutral)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Permanent Employees", size(vlarge) color(black)) ///
name(temp0_X_EG_Ologit_fe2, replace)

graph save "temp0_X_EG_Ologit_fe2", replace

*	Temporary Employees
combomarginsplot temp1_X_EG0 temp1_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Domestic" 2 "Globalized", labsize(vlarge)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Neutral)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Temporary Employees", size(vlarge) color(black)) ///
name(temp1_X_EG_Ologit_fe2, replace)

graph save "temp1_X_EG_Ologit_fe2", replace

*	Combined
graph combine "temp1_X_EG_Ologit_fe2" "temp0_X_EG_Ologit_fe2", ycommon ///
title("Temporary Work Status", color(black)) scheme(s2color) graphregion(color(white))

graph export "MS_reduced_emp_glob_X_temp_worker_Ologit_fe2.png", replace 

********************************************************************************
*	mgmt_dum*emp_glob interaction
********************************************************************************

*	Having an executive position is another measure of skill level (besides education)

ologit trade3 i.emp_glob##mgmt_dum collgrad   ///
   female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
margins, at(mgmt_dum=0 emp_glob=0 (median)    ///
 female  union age collgrad (means) ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(mgmt_dum0_X_EG0, replace)
 
margins, at(mgmt_dum=0 emp_glob=1 (median)    ///
 female  union age collgrad (means) ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(mgmt_dum0_X_EG1, replace)
 
margins, at(mgmt_dum=1 emp_glob=0 (median)    ///
 female  union age collgrad (means) ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(mgmt_dum1_X_EG0, replace)

margins, at(mgmt_dum=1 emp_glob=1 (median)    ///
 female  union age collgrad (means) ) predict(outcome(2)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(mgmt_dum1_X_EG1, replace)  
 
*	Non-Executives 
combomarginsplot mgmt_dum0_X_EG0 mgmt_dum0_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Domestic" 2 "Globalized", labsize(vlarge)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Agree)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Non-Managers", size(vlarge) color(black)) ///
name(mgmt_dum0_X_EG_Ologit_fe, replace)

graph save "mgmt_dum0_X_EG_Ologit_fe2", replace

*	Executives
combomarginsplot mgmt_dum1_X_EG0 mgmt_dum1_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Domestic" 2 "Globalized", labsize(vlarge)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Agree)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Managers", size(vlarge) color(black)) ///
name(mgmt_dum1_X_EG_Ologit_fe, replace)

graph save "mgmt_dum1_X_EG_Ologit_fe2", replace

*	Combined
graph combine "mgmt_dum0_X_EG_Ologit_fe2" "mgmt_dum1_X_EG_Ologit_fe2", ycommon ///
title("Job Role", color(black)) scheme(s2color) graphregion(color(white))

graph export "MS_reduced_emp_glob_X_mgmt_dum_Ologit_fe2.png", replace
 
********************************************************************************
*	NNT hypothesis 3:
*	*Intra-firm Variation*
******************************************************************************** 
*Figure A.9 P(Protection) = “Disagree”
******************************************************************************** 
*	job insecurity*emp_glob interaction
********************************************************************************
*	Dichotomizing 
	
ologit trade3 emp_glob##job_notsafe collgrad   ///
  female age  union  ///
 ind_dum2-ind_dum21, cluster(industry)
 
margins, at(job_notsafe=0 emp_glob=0 (median) collgrad   ///
 female  union age (means) ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(JNS0_X_EG0, replace)
 
margins, at(job_notsafe=0 emp_glob=1 (median) collgrad   ///
 female  union age (means) ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(JNS0_X_EG1, replace)
 
margins, at(job_notsafe=1 emp_glob=0 (median) collgrad   ///
 female  union age (means) ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(JNS1_X_EG0, replace)

margins, at(job_notsafe=1 emp_glob=1 (median) collgrad   ///
 female  union age (means) ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(JNS1_X_EG1, replace)  

*	Job Secure 
combomarginsplot JNS0_X_EG0 JNS0_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Domestic" 2 "Globalized", labsize(vlarge)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Disagree)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Job Secure", size(vlarge) color(black)) ///
name(JNS0_X_EG, replace)

graph save "JNS0_X_EG_Ologit_fe1", replace

*	Job Not Secure
combomarginsplot JNS1_X_EG0 JNS1_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Domestic" 2 "Globalized", labsize(vlarge)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Disagree)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Job Not Secure", size(vlarge) color(black)) ///
name(JNS1_X_EG, replace) 

graph save "JNS1_X_EG_Ologit_fe1", replace

*	Combined
graph combine "JNS1_X_EG_Ologit_fe1" "JNS0_X_EG_Ologit_fe1", ycommon ///
title("Job Security", color(black)) scheme(s2color) graphregion(color(white))

graph export "MS_reduced_emp_glob_X_job_notsafe_Ologit_fe1.png", replace

******************************************************************************** 
*	temp_worker*emp_glob interaction
********************************************************************************
	
*	Temporary Work status is another measure of job security

ologit trade3 i.emp_glob##temp_worker collgrad  ///
   female age  union  ///
 ind_dum2-ind_dum21, cluster(industry)
 
margins, at(temp_worker=0 emp_glob=0 (median)   ///
 female  union age collgrad (means) ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(temp0_X_EG0, replace)
 
margins, at(temp_worker=0 emp_glob=1 (median)   ///
 female  union age collgrad (means) ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(temp0_X_EG1, replace)
 
margins, at(temp_worker=1 emp_glob=0 (median)   ///
 female  union age collgrad (means) ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(temp1_X_EG0, replace)

margins, at(temp_worker=1 emp_glob=1 (median)   ///
 female  union age collgrad (means) ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(temp1_X_EG1, replace)  
 
*	Permanent Employees 
combomarginsplot temp0_X_EG0 temp0_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Domestic" 2 "Globalized", labsize(vlarge)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Disagree)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Permanent Employees", size(vlarge) color(black)) ///
name(temp0_X_EG_Ologit_fe1, replace)

graph save "temp0_X_EG_Ologit_fe1", replace

*	Temporary Employees
combomarginsplot temp1_X_EG0 temp1_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Domestic" 2 "Globalized", labsize(vlarge)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Disagree)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Temporary Employees", size(vlarge) color(black)) ///
name(temp1_X_EG_Ologit_fe1, replace)

graph save "temp1_X_EG_Ologit_fe1", replace

*	Combined
graph combine "temp1_X_EG_Ologit_fe1" "temp0_X_EG_Ologit_fe1", ycommon ///
title("Temporary Work Status", color(black)) scheme(s2color) graphregion(color(white))

graph export "MS_reduced_emp_glob_X_temp_worker_Ologit_fe1.png", replace 

********************************************************************************
*	mgmt_dum *emp_glob interaction
********************************************************************************
*	Having an executive position is another measure of skill level (besides education)

ologit trade3 i.emp_glob##mgmt_dum collgrad   ///
   female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
margins, at(mgmt_dum=0 emp_glob=0 (median)    ///
 female  union age collgrad (means) ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(mgmt0_X_EG0, replace)
 
margins, at(mgmt_dum=0 emp_glob=1 (median)    ///
 female  union age collgrad (means) ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(mgmt0_X_EG1, replace)
 
margins, at(mgmt_dum=1 emp_glob=0 (median)    ///
 female  union age collgrad (means) ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(mgmt1_X_EG0, replace)

margins, at(mgmt_dum=1 emp_glob=1 (median)    ///
 female  union age collgrad (means) ) predict(outcome(1)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)') saving(mgmt1_X_EG1, replace)  
 
*	Non-Executives 
combomarginsplot mgmt0_X_EG0 mgmt0_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Domestic" 2 "Globalized", labsize(vlarge)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Disagree)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Non-Managers", size(vlarge) color(black)) ///
name(mgmt_self0_X_EG_Ologit_fe1, replace)

graph save "mgmt_dum0_X_EG_Ologit_fe1", replace

*	Executives
combomarginsplot mgmt1_X_EG0 mgmt1_X_EG1, recast(scatter) ///
xscale(range(0.5(0.5)2.5)) xlabel(1 "Domestic" 2 "Globalized", labsize(vlarge)) xtitle("", size(vlarge)) ///
ytitle("Protection: P(Disagree)", size(vlarge)) ///
ylabel(, labsize(vlarge)) ///
xsca(titlegap(4))	/// *adds gap between title and labels
scheme(s2color) graphregion(color(white)) ///
title("Managers", size(vlarge) color(black)) ///
name(mgmt_self1_X_EG_Ologit_fe1, replace)

graph save "mgmt_dum1_X_EG_Ologit_fe1", replace

*	Combined
graph combine "mgmt_dum0_X_EG_Ologit_fe1" "mgmt_dum1_X_EG_Ologit_fe1", ycommon ///
title("Job Role", color(black)) scheme(s2color) graphregion(color(white))

graph export "MS_reduced_emp_glob_X_mgmt_dum_Ologit_fe1.png", replace
 
********************************************************************************
*Ordinal Education Coding*
********************************************************************************

eststo clear

set more off


recode ed_attain (1/7=.) (8=1) (9=2) (10=3) (11=4) (12=5) (13=6), gen(ed_attain_ord)
	label var ed_attain_ord "Highest Education Attained (New System Only)"
	label define ed_attain_ord 1 "Junior High School" 2 "High School" ///
	3 "College of Technology" 4 "2-year College" 5 "University" ///
	6 "Graduate School"
	label values ed_attain_ord ed_attain_ord

********************************************************************************
*	Table A7 (Testing H1)
********************************************************************************

set more off

*	Model1: Base Model
eststo tab1_h1: reg trade ed_attain_ord emp_glob  ///
   female age union ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
*	Model2: Base Model + disadvantaged industry 
eststo tab1_h1a: reg trade ed_attain_ord emp_glob ///
   female age union comp_disadv  ///
 , cluster(industry)
*	Model3: Base Model + localism
eststo tab1_h1b: reg trade ed_attain_ord emp_glob  ///
   female age union  localism ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
*	Model 4: Base Model + LDP - redistribution
eststo tab1_h1c: reg trade ed_attain_ord emp_glob   ///
   female age union LDP ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
*	Model 5: Base Model + occupational controls
	eststo tab1_h1d: reg trade ed_attain_ord emp_glob  ///
	  female age union  ///
	 task_routine task_offshorability ///
	 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
	 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
	 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
*	Model 6: attitudinal controls
eststo tab1_h1e: reg trade ed_attain_ord emp_glob  ///
  female age union glob_workers redistribution cosmo_avg jobloss_prob ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

 
esttab tab1_h1 tab1_h1a tab1_h1b tab1_h1c tab1_h1d tab1_h1e ///
 using "AP_tab1_ord_ed_reduced.tex", ///
	replace label nogap  b(2) se  /// 
	star(* 0.10 ** 0.05 *** 0.01)  ///
	ti(Firm Characteristics and Support for Protection (Ordinal Education)) 

eststo clear
	
*	Table A8 (Testing H2)
********************************************************************************
set more off  

*	Model1: emp_glob X comp_disadv
eststo tab2_h2_ind: xi: reg trade i.emp_glob*comp_disadv ed_attain_ord  ///
	 female age union, cluster(industry) 

*	Model2: emp_glob X ed_attain_ord
eststo tab2_h2_skill: xi: reg trade i.emp_glob*ed_attain_ord  ///
	 female age union ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
  
*	Model 3: emp_glob X task_offshorability interaction
eststo tab2_offshore: xi: reg trade  ed_attain_ord i.emp_glob*task_offshorability task_routine  ///
  female age union ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
*	Model 4: task_routine X task_offshorability interaction 
eststo tab2_routine_offshore: reg trade emp_glob  ed_attain_ord c.task_routine##c.task_offshorability ///
  female age union ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
*	Model 5: task_routine X task_offshorability interaction for domestic employers 
eststo tab2_routine_offshore_0: reg trade ed_attain_ord c.task_routine##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==0, cluster(industry)

*	Model 6: task_routine X task_offshorability interaction for globalized employers  
eststo tab2_routine_offshore_1: reg trade ed_attain_ord c.task_routine##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==1, cluster(industry)
 
  
*	Make Table 2:
esttab tab2_h2_ind tab2_h2_skill tab2_offshore tab2_routine_offshore  ///
	tab2_routine_offshore_0 tab2_routine_offshore_1 ///
	using "AP_tab2_ord_ed_reduced.tex", ///
	replace label nogap  b(2) se  /// 
	star(* 0.10 ** 0.05 *** 0.01)  ///
	ti(Conditional Effects of Firm Productivity (Ordinal Education))
	
eststo clear

*	Table A9 (Hypothesis 3 Testing)
********************************************************************************
set more off
 
*	Model2: emp_glob X jobloss_prob
eststo tab3_h3_1: xi: reg trade i.emp_glob*jobloss_prob ed_attain_ord ///
   female age union ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

*	Model3: emp_glob X temp_worker
eststo tab3_h3_2: xi: reg trade i.emp_glob*temp_worker ed_attain_ord ///
   female age union ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

*	Model4: emp_glob X mgmt
eststo tab3_h3_3: xi: reg trade i.emp_glob*mgmt_dum ed_attain_ord ///
   female age union ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
  

*	Make Table 3:
esttab /*tab3_base*/ tab3_h3_1 tab3_h3_2 tab3_h3_3 /*tab3_h3_4*/ /*tab3_h3_5*/ /*tab3_h3_6*/ ///
 using "AP_tab3_ord_ed_reduced.tex", ///
	replace label nogap  b(2) se  /// 
	star(* 0.10 ** 0.05 *** 0.01)  ///
	ti(Employee Status and Firm Productivity (Ordinal Education))
	
eststo clear

********************************************************************************
* Alternative Employer Type Codings *
********************************************************************************

*	Table A.10 (Testing H1)
********************************************************************************]

*	Model1: Base Model
eststo tab1_h1: reg trade collgrad emp_glob_ord  ///
female age  union ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)


*	Model2: Base Model + disadvantaged industry
eststo tab1_h1a: reg trade collgrad emp_glob_ord  ///
 female age  union comp_disadv ///
, cluster(industry)


*	Model3: Base Model + localism
eststo tab1_h1b: reg trade collgrad emp_glob_ord  ///
 female age  union  localism ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)


*	Model 4: Base Model + LDP - 
eststo tab1_h1c: reg trade collgrad emp_glob_ord   ///
 female age LDP union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

 
*	Model 5: Base Model + occupational controls
eststo tab1_h1d: reg trade collgrad  emp_glob_ord  ///
 female age  union  ///
 task_routine task_offshorability ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

 
*	Model 6: attitudinal controls
eststo tab1_h1e: reg trade collgrad emp_glob_ord ///
 female age union redistribution cosmo_avg glob_workers jobloss_prob  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

 
esttab tab1_h1 tab1_h1a tab1_h1b tab1_h1c tab1_h1d tab1_h1e ///
 using "AP_tab1_ord_emp_reduced.tex", ///
	replace label nogap  b(2) se  /// 
	star(* 0.10 ** 0.05 *** 0.01)  ///
	ti(Firm Characteristics and Support for Protection (Ordinal Employer Type)) 

eststo clear
	
*	Table A.11 (Testing H2)
********************************************************************************
set more off

*	Model1: emp_glob_ord X comp_disadv
eststo tab2_h2_sector: reg trade c.emp_glob_ord##i.comp_disadv collgrad ///
 female age  union, cluster(industry)
 
*	Model2: emp_glob_ord X collgrad
eststo tab2_h2_skill: xi: reg trade c.emp_glob_ord##i.collgrad ///
 female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
  
*	Model 3: emp_glob_ord X task_offshorability interaction
eststo tab2_offshore: xi: reg trade collgrad c.emp_glob_ord##c.task_offshorability task_routine ///
 female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
*	Model 4: task_routine X task_offshorability interaction 
	eststo tab2_routine_offshore: reg trade  collgrad emp_glob_ord c.task_routine##c.task_offshorability  ///
	 female age  union ///
	 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
	 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
	 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
	  
*	Make Table 2:
esttab tab2_h2_sector tab2_h2_skill tab2_offshore tab2_routine_offshore ///
 using "AP_tab2_ord_emp_reduced.tex", ///
	replace label nogap  b(2) se  /// 
	star(* 0.10 ** 0.05 *** 0.01)  ///
	ti(Conditional Effects of Firm Productivity (Ordinal Employer Type))
	
eststo clear

*	Table A.12 (Hypothesis 3 Testing)
********************************************************************************

eststo clear
set more off


*	Model2: emp_glob_ord X jobloss_prob
eststo tab3_h3_1: reg trade c.emp_glob_ord##c.jobloss_prob collgrad ///
 female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

*	Model3: emp_glob_ord X temp_worker
eststo tab3_h3_2: reg trade c.emp_glob_ord##i.temp_worker collgrad ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

*	Model4: emp_glob_ord X mgmt
eststo tab3_h3_3: xi: reg trade c.emp_glob_ord##i.mgmt_dum collgrad ///
 female age union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)


*	Make Table 1:
esttab /*tab3_base*/ tab3_h3_1 tab3_h3_2 tab3_h3_3 ///
 using "AP_tab3_ord_emp_reduced.tex", ///
	replace label nogap  b(2) se  /// 
	star(* 0.10 ** 0.05 *** 0.01)  ///
	ti(Employee Status and Firm Productivity (Ordinal Employer Type))
	
eststo clear

********************************************************************************
 *Controls for Local Economic Interests
********************************************************************************
*	Table A.13 
********************************************************************************

eststo clear

*	Firm Size
eststo tab5_size: reg trade collgrad emp_glob empsize ///
female age union ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
	
*	Prefecture-Level TFP	
eststo tab5_tfp: reg trade collgrad emp_glob ///
 female age union /// 
 tfp ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

*	Prefecture-Level Labor Productivity
eststo tab5_lp: reg trade collgrad emp_glob ///
 female age union /// 
 labor_prod ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)

*	RTFPIR (TFP by industry and prefecture) 
eststo tab5_rtfpir: reg trade collgrad emp_glob ///
 female age union rtfpir /// 
, cluster(industry)

*	Make Table 3:
esttab tab5_size tab5_tfp tab5_lp tab5_rtfpir ///
 using "Tables/AP_geo_fe.tex", ///
	replace label nogap  b(2) se  /// 
	star(* 0.10 ** 0.05 *** 0.01)  ///
	ti(Local Productivity and Support for Protection)

	
********************************************************************************
 *Alternative Task Measures*
********************************************************************************
*Using Alan Blinder's Task Offshorability Measures:

use "JGSS 2008_Blinder.dta", clear

eststo clear

set more off

*	Create industry dummies for industry fixed effects 
tab industry, gen(ind_dum) 
	*NB: Agriculture will be reference industry
*	Here, we're not going to stratify by employer type because the sample size is too small


*	Table A.14 (Testing H2)
********************************************************************************
recode Score (76/100=4) (51/75=3) (26/50=2) (1/25=1), gen(b_offshore_ord)
	label var b_offshore_ord "Blinder Ordinal Offshorability Scores"
	label define b_offshore_ord 1 "Highly non-offshorable" 2 "Non-offshorable" ///
	3 "Offshorable" 4 "Highly offshorable"
	label values b_offshore_ord b_offshore_ord

set more off  

*	Model1: emp_glob X comp_disadv
eststo tab2_h2_ind: xi: reg trade i.emp_glob*comp_disadv collgrad  ///
	 female age  union , cluster(industry) 
	
*	Model2: emp_glob X collgrad
eststo tab2_h2_skill: xi: reg trade i.emp_glob*collgrad  ///
	 female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)	
	  
*	Model 3: emp_glob X task_offshorability interaction
eststo tab2_offshore: xi: reg trade  collgrad i.emp_glob*Score task_routine  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
*	Model 4: task_routine X task_offshorability interaction 
eststo tab2_routine_offshore: reg trade emp_glob  collgrad c.task_routine##c.Score  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
  
 
*	Make Table 2:
esttab tab2_h2_ind tab2_h2_skill tab2_offshore tab2_routine_offshore ///
   using "AP_tab2_industry_fe_blinder_reduced.tex", ///
	replace label nogap  b(2) se  /// 
	star(* 0.10 ** 0.05 *** 0.01)  ///
	ti(Conditional Effects of Firm Productivity (Blinder Measures))

eststo clear
	
********************************************************************************
*Using A&A Task Routiness Measure*

*	Table A.15 (Testing H2)
********************************************************************************


use "JGSS 2008_AA_2011.dta", clear

eststo clear

set more off

*	Create industry dummies for industry fixed effects 
tab industry, gen(ind_dum) 
	*NB: Agriculture will be reference industry

rename r_2011 task_routine_2011	

*	Table 2 (Testing H2)
********************************************************************************

set more off  

*	Model1: emp_glob X comp_disadv
eststo tab2_h2_ind: xi: reg trade i.emp_glob*comp_disadv collgrad  ///
	 female age  union, cluster(industry) 
	
*	Model2: emp_glob X collgrad
eststo tab2_h2_skill: xi: reg trade i.emp_glob*collgrad  ///
	 female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)	
	  
*	Model 3: emp_glob X task_offshorability interaction
eststo tab2_offshore: xi: reg trade  collgrad i.emp_glob*task_offshorability task_routine_2011  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
*	Model 4: task_routine X task_offshorability interaction 
eststo tab2_routine_offshore: reg trade emp_glob collgrad c.task_routine_2011##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry)
 
 
*	Model 5: task_routine X task_offshorability interaction for domestic employers 
eststo tab2_routine_offshore_0: reg trade collgrad c.task_routine_2011##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==0, cluster(industry)

*	Model 6: task_routine X task_offshorability interaction for globalized employers  
eststo tab2_routine_offshore_1: reg trade collgrad c.task_routine_2011##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==1, cluster(industry) 
 

  
*	Make Table 2:
esttab tab2_h2_ind tab2_h2_skill tab2_offshore tab2_routine_offshore  ///
     tab2_routine_offshore_0 tab2_routine_offshore_1 ///
   using "AP_tab2_industry_fe_aa_2011_reduced.tex", ///
	replace label nogap  b(2) se  /// 
	star(* 0.10 ** 0.05 *** 0.01)  ///
	ti(Conditional Effects of Firm Productivity (A \& A (2011) Measures))

	
eststo clear


*Using A&D (2013) AKA RTI*

*	Table A.16 (Testing H2)
********************************************************************************

set more off  

*	Model1: emp_glob X comp_disadv
eststo tab2_h2_ind: xi: reg trade i.emp_glob*comp_disadv collgrad ///
	 female age union, cluster(industry) 
	
*	Model2: emp_glob X collgrad
eststo tab2_h2_skill: xi: reg trade i.emp_glob*collgrad ///
	 female age union ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21,cluster(industry) 
	  
*	Model 3: emp_glob X task_offshorability interaction
eststo tab2_offshore: xi: reg trade collgrad i.emp_glob*task_offshorability RTI  ///
  female age union ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21,cluster(industry) 
 
*	Model 4: task_routine X task_offshorability interaction 
eststo tab2_routine_offshore: reg trade emp_glob collgrad c.RTI##c.task_offshorability ///
  female age union ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21, cluster(industry) 
 
*	Model 5: task_routine X task_offshorability interaction for domestic employers 
eststo tab2_routine_offshore_0: reg trade collgrad c.RTI##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==0, cluster(industry)

*	Model 6: task_routine X task_offshorability interaction for globalized employers  
eststo tab2_routine_offshore_1: reg trade collgrad c.RTI##c.task_offshorability  ///
  female age  union  ///
 ind_dum2 ind_dum3 ind_dum4 ind_dum5 ind_dum6 ind_dum7 ind_dum8 ind_dum9 ///
 ind_dum10 ind_dum11 ind_dum12 ind_dum13 ind_dum14 ind_dum15 ind_dum16 ///
 ind_dum17 ind_dum18 ind_dum19 ind_dum20 ind_dum21 if emp_glob==1, cluster(industry) 
 
  
*	Make Table A.13:
esttab tab2_h2_ind tab2_h2_skill tab2_offshore tab2_routine_offshore ///
	tab2_routine_offshore_0 tab2_routine_offshore_1 ///
    using "AP_tab2_industry_fe_RTI.tex", ///
	replace label nogap  b(2) se  /// 
	star(* 0.10 ** 0.05 *** 0.01)  ///
	ti(Conditional Effects of Firm Productivity (Routine Task Intensity))

eststo clear

********************************************************************************
*Manufacturing vs. Services Employment
********************************************************************************
*Figure A12 

 *	Compare by manufacturing or sector
reg trade collgrad i.emp_glob##i.manu_serv ///
  female age union, cluster(industry) 
 
margins, at((mean)_all manu_serv=1 emp_glob=0 collgrad=0 ///
 female=0 union=0) ///
at((mean)_all manu_serv=2 emp_glob=0 collgrad=0  ///
 female=0 union=0) /// 
at((mean)_all manu_serv=1 emp_glob=1 collgrad=0  ///
 female=0 union=0) ///
at((mean)_all manu_serv=2 emp_glob=1 collgrad=0 ///
 female=0 union=0) 

marginsplot, plotopts(c(none) mcolor(black)) legend(off) graphregion(color(white))   ///
ciopts(lcolor(black)) ylabel(, angle(horizontal) notick labsize(vlarge)) ///
 xscale(range(.7(.5)4.3) titlegap(4)) xlabel(1 `" "Domestic" "Manufacturing" "' ///
 2 `" "Domestic" "Services" "' 3 `" "Globalized" "Manufacturing" "' ///
 4 `" "Globalized" "Services" "', labsize(large) nogrid notick) /// 
 yscale(range(3.8 4.8) titlegap(4)) ylabel(3.8(0.2)4.8) ///
 ytitle("Protection: Predicted Value", size(vlarge)) ///
 xtitle("", size(large))  ///
 title("Services vs. Manufacturing", color(black) size(vlarge)) ///
 level(`=round((normal(1)-normal(-1))*100,.01)')

graph export "MS_reduced_base_ols_manu_serv.png", replace

********************************************************************************
*Multiple Imputation*
********************************************************************************	 

use "JGSS 2008.dta", clear

	set more off

	*   Declare Data as Mi Data 
	mi set mlong
	*   Check Variables for Missing
	misstable summarize trade collgrad jobloss_prob emp_glob glob_workers  ///
	female age temp_worker redistribution union cosmo_avg realism localism LDP comp_disadv ///
	industry region mgmt_dum task_routine task_offshorability jobloss_prob job_satisfaction
	

*   Register Imputed 
	mi register imputed temp_worker jobloss_prob glob_workers ///
	 union emp_glob task_routine task_offshorability ///
	job_satisfaction comp_disadv ///
	 collgrad LDP trade redistribution realism localism cosmo_avg early_achiever class_origin ///
	 mgmt_dum region hq 
	 
	*   Register non-Imputed 
	mi register regular female age 
	
	*   Run Imputation 			 

	*	Base model imputation:
mi impute chained ///
 (pmm, knn(5)) task_routine task_offshorability cosmo_avg ///
(ologit) job_satisfaction jobloss_prob realism localism redistribution class_origin early_achiever glob_workers ///
 (mlogit) region ///
(logit) emp_glob collgrad union temp_worker LDP comp_disadv hq mgmt_dum, noisily ///
 augment add(10) rseed(19920512) 

************************************************************** 
*	Analysis:
************************************************************** 
*	Create industry dummies for industry fixed effects 
tab industry, gen(ind_dum) 

	*NB: Agriculture will be reference industry

save "JGSS_MI_IO.dta", replace 
use "JGSS_MI_IO.dta"

eststo clear

*	Table A17 (Testing H1)
********************************************************************************
*	Model1: Base Model
eststo tab1_h1: mi estimate, post: reg trade collgrad emp_glob ///
female age union ind_dum2-ind_dum20, cluster(industry)
 
*	Model2: Base Model + comp_disadv
	eststo tab1_h1a: mi estimate, post: reg trade collgrad emp_glob  ///
	female age union comp_disadv , cluster(industry)

*	Model3: Base Model + localism
eststo tab1_h1b: mi estimate, post: reg trade collgrad emp_glob  ///
female age union localism ind_dum2-ind_dum20, cluster(industry)

*	Model 4: Base Model + LDP - redistribution
eststo tab1_h1c: mi estimate, post: reg trade collgrad emp_glob  ///
  female age union LDP ind_dum2-ind_dum20, cluster(industry)

*	Model 5: Base Model + occupational controls
eststo tab1_h1d: mi estimate, post: reg trade collgrad emp_glob  ///
 female age union  ///
 task_routine task_offshorability ind_dum2-ind_dum20, cluster(industry)
 
*	Model 6: Base Model + post-treatment variables
eststo tab1_h6: mi estimate, post: reg trade collgrad emp_glob glob_workers  ///
 female age union redistribution cosmo_avg jobloss_prob ind_dum2-ind_dum20, cluster(industry)

esttab tab1_h1 tab1_h1a tab1_h1b tab1_h1c tab1_h1d tab1_h6 ///
 using "tab1_fe_MI_strata.tex", ///
	replace label nogap  b(2) se  /// 
	star(* 0.10 ** 0.05 *** 0.01)  ///
	ti(Firm Characteristics and Support for Protection) 
			
eststo clear

*	Table A18 (Testing H2)
********************************************************************************
set more off  


mi passive: gen emp_glob_comp_disadv = emp_glob*comp_disadv 
mi passive: gen emp_glob_collgrad = emp_glob*collgrad 
mi passive: gen emp_glob_task_off = emp_glob*task_offshorability 
mi passive: gen task_routine_off = task_routine*task_offshorability

*	Model1: emp_glob X comp_disadv
eststo tab2_h2_ind: xi: mi estimate, post: reg trade emp_glob_comp_disadv emp_glob comp_disadv collgrad ///
	 female age union ///
	, cluster(industry) 
		
*	Model2: emp_glob X collgrad
eststo tab2_h2_skill:xi: mi estimate, post: reg trade emp_glob_collgrad emp_glob collgrad ///
	female age union ///
	 ind_dum2-ind_dum20, cluster(industry)

*	Model 3: emp_glob X task_offshorability interaction
	eststo tab2_offshore: xi: mi estimate, post: reg trade emp_glob_task_off emp_glob task_offshorability task_routine ///
	collgrad female age union ind_dum2-ind_dum20, cluster(industry)
	

*	Model 4: task_routine X task_offshorability interaction 
eststo tab2_routine_offshore: xi: mi estimate, post: reg trade emp_glob collgrad task_routine_off task_routine task_offshorability  ///
female age union ind_dum2-ind_dum20, cluster(industry)  

*	Make Table 2:
esttab tab2_h2_ind  tab2_h2_skill tab2_offshore tab2_routine_offshore ///
 using "tab2_fe_MI_strata.tex", ///
	replace label nogap  b(2) se  /// 
	star(* 0.10 ** 0.05 *** 0.01)  ///
	ti(Conditional Effects of Firm Productivity (Industry Fixed Effects))
	
*	Table A19 (Hypothesis 3 Testing)
********************************************************************************
set more off

mi passive: gen emp_glob_jobloss = emp_glob*jobloss_prob
mi passive: gen emp_glob_temp = emp_glob*temp_worker 
mi passive: gen emp_glob_mgmt = emp_glob*mgmt_dum 

*	Model2: emp_glob X jobloss_prob
eststo tab3_h3_1: xi: mi estimate, post: reg trade emp_glob_jobloss emp_glob jobloss_prob collgrad ///
 female age union ///
 ind_dum2-ind_dum20, cluster(industry)

 	
*	Model3: emp_glob X temp_worker
eststo tab3_h3_2: xi: mi estimate, post: reg trade emp_glob_temp emp_glob temp_worker collgrad ///
 female age union ///
 ind_dum2-ind_dum20, cluster(industry)
 

*	Model4: emp_glob X mgmt
eststo tab3_h3_3: xi: mi estimate, post: reg trade emp_glob_mgmt emp_glob mgmt_dum collgrad ///
 female age union ///
 ind_dum2-ind_dum20, cluster(industry)

*	Make Table 3:
esttab tab3_h3_1 tab3_h3_2 tab3_h3_3 ///
 using "tab3_fe_MI_strata.tex", ///
	replace label nogap  b(2) se  /// 
	star(* 0.10 ** 0.05 *** 0.01)  ///
	ti(Conditional Effects of Firm Productivity (Industry Fixed Effects))
